package de.hwr.sudokuspielehr.ui.listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import de.hwr.sudokuspielehr.ui.UserInterface;

public class QuestionButtonListener implements ActionListener {

	private UserInterface ui;

	public QuestionButtonListener(UserInterface pUi) {
		ui = pUi;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if (ui.getActivePanel() == UserInterface.PANEL_SUDOKUPLAYPANEL) {
			if (ui.getStatus() == UserInterface.TIP_SCAN) {
				ui.openHelperFrame(UserInterface.TIP_SCAN_INDEX);
			} else if (ui.getStatus() == UserInterface.TIP_GROUP) {
				ui.openHelperFrame(UserInterface.TIP_GROUP_INDEX);
			} else if (ui.getStatus() == UserInterface.TIP_COLUMNS) {
				ui.openHelperFrame(UserInterface.TIP_COLUMNS_INDEX);
			} else if (ui.getStatus() == UserInterface.TIP_ROWS) {
				ui.openHelperFrame(UserInterface.TIP_ROWS_INDEX);
			} else if (ui.getStatus() == UserInterface.TIP_ELIMINATE) {
				ui.openHelperFrame(UserInterface.TIP_ELIMINATE_INDEX);
			} else if (ui.getStatus() == UserInterface.TIP_HELPNUMBERS_ACTIVATED || ui.getStatus() == UserInterface.TIP_HELPNUMBERS_DEACTIVATED
					|| ui.getStatus().contains("Hilfszahl")) {
				ui.openHelperFrame(UserInterface.TIP_HELPNUMBERS_INDEX);
			} else {
				ui.openHelperFrame(UserInterface.TIP_RULES_INDEX);
			}
		} else if (ui.getActivePanel() == UserInterface.PANEL_MAINMENUPANEL) {
			ui.openHelperFrame(UserInterface.TIP_COLORS_INDEX);
		} else if (ui.getActivePanel() == UserInterface.PANEL_CREATEMENUPANEL) {
			if (ui.isInCreatorMode() && ui.containsErrorInCreatorMode()) {
				ui.openHelperFrame(UserInterface.TIP_CREATORMODE_ERROR_INDEX);
			} else if (ui.isInCreatorMode()) {
				ui.openHelperFrame(UserInterface.TIP_CREATE_INDEX);
			}
		} else if (ui.getActivePanel() == UserInterface.PANEL_GENERATEMENUPANEL) {
			ui.openHelperFrame(UserInterface.TIP_GENERATOR_INDEX);
		} else if (ui.getActivePanel() == UserInterface.PANEL_LOADMENUPANEL) {
			ui.openHelperFrame(UserInterface.TIP_LOAD_INDEX);
		}
	}
}
